#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int lengthOfLastWord(const char *s) {
        if(s == NULL || *s == '\0')
            return 0;
        const char* p1 = s;
        const char* p2 = s;
        // find the last one world
        while(*p2!='\0') p2++;
        p2--;
        while(p2>s && *p2==' ')p2--;
        printf("%d\n", p2 - s);
        p1 = p2;
        if(p1>s)
        {
            while(p1>s && *p1!=' ') p1--;
            if(*p1 == ' ')
                p1++;
        }
        if(p2 == p1 && *p2 == ' ')
            return 0;
        return p2 - p1 + 1;
    }

int main(int argc, char const *argv[])
{
    char* s = " a";
    printf("%d\n", lengthOfLastWord(s));
    return 0;
}